﻿#ifndef CHANGEPASSWORD_H
#define CHANGEPASSWORD_H
#include"email.h"
#include"emailwindow.h"
#include <QGraphicsDropShadowEffect>
#include <QGraphicsOpacityEffect>
#include <QGraphicsEffect>
#include <QPropertyAnimation>
#include <QParallelAnimationGroup>
#include <QSequentialAnimationGroup>
class SheildLayer : public QWidget{
    Q_OBJECT

private:
    bool pressed = false;
    bool enabled = true;
    QWidget *bg;
    void mousePressEvent(QMouseEvent *event){if(enabled)pressed = true;}
    void mouseReleaseEvent(QMouseEvent *event){if(enabled && pressed)emit clicked();pressed = false;}
    void resizeEvent(QResizeEvent *event){bg->resize(this->parentWidget()->size());}
public:
    SheildLayer(QWidget *parent = nullptr) : QWidget(parent){
        bg = new QWidget(this);
        bg->resize(parent->size());
        bg->setStyleSheet("background-color:#5a000000");
        bg->setAttribute(Qt::WA_TransparentForMouseEvents);
        bg->show();
    }
    void setEnabled(bool e){enabled = e;}
signals:
    void clicked();
};
namespace Ui {
class ChangePassword;
}

class ChangePassword : public QWidget
{
    Q_OBJECT

public:
    explicit ChangePassword(QWidget *parent = nullptr);
    ~ChangePassword();

private slots:
    void on_confirm_clicked();

    void on_sendcode_clicked();

    void on_cancel_clicked();

    void processRet();


private:
    Ui::ChangePassword *ui;
    Email *email;
    int cornerRadius;
    QString pageName;
    QWidget * bgWidget;
    SheildLayer * sheildLayer;

    bool onShown=false;
    QParallelAnimationGroup * curAni=nullptr;
    QGraphicsOpacityEffect * opacity;
signals:
    void sizeChange();
public slots:
    void sildeIn();
    void sildeOut();
};

#endif // CHANGEPASSWORD_H
